#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:chengyanan
@file: red_ini.py
@time: 2019/12/18  10:18 下午
"""
import os
import sys
path = os.path.dirname(os.getcwd())
sys.path.append(path)
import configparser


class ReadIni:
    def __init__(self, file_name=None, node=None):
        if file_name == None:
            file_name = "../config/localElement.ini"
        self.cf = self.load_ini(file_name)
        if node == None:
            self.node = 'Registerelement'
        else:
            self.node = node


    def load_ini(self, file_name=None):
        # 定义一个对象
        cf = configparser.ConfigParser()
        # 取上级标签
        cf.read(file_name)
        return cf
#
# node是节点：[Registerelement]
# key是值:user_name
#
    def get_value(self,key):
        data=self.cf.get(self.node,key)
        return data


if __name__ == '__main__':
    read_init=ReadIni()
    print(read_init.get_value("user_name"))
